$(function ()
{
    findById();
})

function findById()
{
    let id = sessionStorage.getItem("hotelid");

    let data = publivAjax('/back/hotel/findById', {id: id}, 'get');

    if (data != null)
    {
        let model = data.model;
        $("#content").val(model.content);
        $("#address").val(model.address);
        $("#phone").val(model.phone);
        $("#fax").val(model.fax);
        $("#email").val(model.email);
        $("#website").val(model.website);
        $("#reservationPhone").val(model.reservationPhone);
        $("#href").attr("src",model.qrCode);
        $("#isShow").val(model.isShow);
        $("#recommend").val(model.recommend);
    }
}

function save()
{
    let msg = new FormData();
    msg.append("id", sessionStorage.getItem("hotelid"));
    msg.append("content", $("#content").val());
    msg.append("address", $("#address").val());
    msg.append("phone", $("#phone").val());
    msg.append("fax", $("#fax").val());
    msg.append("email", $("#email").val());
    msg.append("website", $("#website").val());
    msg.append("reservationPhone", $("#reservationPhone").val());
    msg.append("qrCode", $("#qrCode")[0].files[0]);
    msg.append("isShow", $("#isShow").val());
    msg.append("recommend", $("#recommend").val());

    let data = uploadAjax('/back/hotel/edit', msg, 'post');

    if (data.count == 1)
    {
        $('#b-right').load('/back/hotel/hotelList.html');
    }
    else
    {
        alert("修改失败！");
    }
}